//
//  EJSMyAccountViewController.m
//  EnjoyShoppingStreet
//
//  Created by lifayu on 2017/12/13.
//  Copyright © 2017年 lifayu. All rights reserved.
//

#import "EJSMyAccountViewController.h"
#import "EJSUserBalanceRequest.h"
#import "EJSAccountBillsViewController.h"
#import "EJSWithdrawalViewController.h"

@interface EJSMyAccountViewController ()

@property (weak, nonatomic) IBOutlet UILabel *balanceLabel;
@property (copy, nonatomic) NSString *balance;
@end

@implementation EJSMyAccountViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"我的账户";
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
     [self getUserBalance];
}

- (void)getUserBalance{
    FlyWeakSelf
    [[EJSUserBalanceRequest new] asyncRequestWithsuccessHandler:^(BaseResponse *response) {
        EJSUserBalanceModel *model = response.data;
        weakSelf.balanceLabel.text = [NSString stringWithFormat:@"€ %@",model.money];
        weakSelf.balance = model.money;
    } failHandler:^(BaseResponse *response) {
        [[HUDHelper sharedInstance] tipMessage:response.message];
    }];
}


#pragma mark - Actions

- (IBAction)withdrawalAction:(UIButton *)sender{
    EJSWithdrawalViewController *vc = [[EJSWithdrawalViewController alloc] initWithNibName:@"EJSWithdrawalViewController" bundle:nil];
    vc.balance = self.balance;
    [self.navigationController pushViewController:vc animated:YES];
}
- (IBAction)checkAccountAction:(UIButton *)sender
{
    EJSAccountBillsViewController *vc = [[EJSAccountBillsViewController alloc] initWithNibName:@"EJSAccountBillsViewController" bundle:nil];
    [self.navigationController pushViewController:vc animated:YES];
}


@end
